extends Node2D

## 玩家
@export var node_player: Sprite2D
## 敌人
@export var node_enemy: Sprite2D

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	var player_area = node_player.find_child("Area2D") as Area2D
	player_area.area_entered.connect(Callable(self, "EnterArea"))
	player_area.area_exited.connect(Callable(self, "ExitArea"))
	pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta: float) -> void:
	#if Input.is_action_just_pressed("跳跃"):
	#	print("刚抬起了跳跃")
	#elif Input.is_action_just_released("跳跃"):
	#	print("刚抬起了跳跃")
	#elif Input.is_action_pressed("跳跃"):
	#	node_player.position += Vector2(1, 0)
	var horizontal: float = Input.get_axis("左", "右")
	node_player.position += Vector2(horizontal, 0)
	
	pass

func EnterArea(area: Area2D):
	if area == (node_enemy.find_child("Area2D") as Area2D):
		print("敌人碰到了")
	pass

func ExitArea(area: Area2D):
	if area == (node_enemy.find_child("Area2D") as Area2D):
		print("敌人离开了")
	pass
